//
//  ApiManager.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/8.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import Moya
import CoreVideo

struct ApiUrl {
    enum ApiEnvironment {
        case produce
        case imProduce
        case noProduce
        case htmlProduce
        case imageProduce
        /// https://health.pmc-wz.com:20211/ysgapp
        var baseURL: String {
            switch self {
            case .produce, .imProduce, .imageProduce: return "https://health.pmc-wz.com:20211"
            case .noProduce: return "https://health.pmc-wz.com:20214"
            default: return ""
            }
        }
        
        var basic: String {
            switch self {
            case .noProduce: return ""
            case .produce: return "/ysgapp"
            case .imProduce: return "/chat"
            case .imageProduce: return "/chat/imserver"
            default: return ""
            }
        }
        
        var webSocketUrl: String {
            switch self {
            case .imProduce:
                return "wss://health.pmc-wz.com:20211/imserver?username=\(UserDefaults.userId)"
            default:
                return ""
            }
        }
        
        var htmlUrl: String {
            switch self {
            case .htmlProduce:
                return "https://health.pmc-wz.com:20213/record/record-list?token=%@&patientId=%@"
            default:
                return ""
            }
        }
        
        var htmlUrl1: String {
            switch self {
            case .htmlProduce:
                return "https://health.pmc-wz.com:20213/banner/index?token=%@"
            default:
                return ""
            }
        }
    }
    
    private static let environment = ApiEnvironment.produce
    private static let imEnv = ApiEnvironment.imProduce
    private static let noEnv = ApiEnvironment.noProduce
    private static let htmlEnv: ApiEnvironment = .htmlProduce
    private static let imageEnv = ApiEnvironment.imageProduce
    
    
    static var domain: String { return environment.baseURL }
    static var basic: String { return environment.basic }
    
    static var noDomain: String { return noEnv.baseURL }
    
    static var imDomain: String { return imEnv.baseURL }
    static var imBasic: String { return imEnv.basic }
    static var wsUrl: String { return imEnv.webSocketUrl }
    static var htmlUrl: String { return htmlEnv.htmlUrl }
    static var htmlUrl1: String { return htmlEnv.htmlUrl1 }
    
    static var imageDomain: String { return imageEnv.baseURL }
    static var imageBasic: String { return imageEnv.basic }
    
    static let login = "/app/userPatient/login"
    static let checkRegistered = "/app/userPatient/IsExist"
    static let sendSmsCode = "/app/userPatient/sendSms"
    static let register = "/app/userPatient/register"
    static let changePassword = "/app/userPatient/passwd"
    static let forgetPassword = "/app/userPatient/forgetPasswd"
    static let logout = "/app/userDoc/logOut"
    static let familyList = "/app/userPatient/familyMemberList"
    static let familyAddOrEdit = "/app/userPatient/insertOrUpdateFamilyMember"
    static let familyDelete = "/app/userPatient/deleteFamilyMember"
    static let cloudClinicList = "/app/outpatientCloud/outpatientCloudPatient"
    static let generateCloudOrder = "/app/outpatientCloud/createOutpatientCloud"
    static let changeCloudStatus = "/app/outpatientCloud/changeOutpReady"
    static let getBindCardList = "/app/userPatient/getCard"
    static let addCard = "/app/userPatient/createCard"
    static let bindCard = "/app/userPatient/bindingCard"
    static let familyMemberDetail = "/app/userPatient/familyMemberInfo"
    static let changePatientPhone = "/app/userPatient/updatePhoneReview"
    static let receiveAddressList = "/app/userPatient/receivingAddressList"
    static let addAndEditReceiveAddress = "/app/userPatient/insertOrUpdateReceivingAddress"
    static let receiveAddressDetail = "/app/userPatient/receivingAddressInfo"
    static let bindDeviceTokenForPush = "/app/userDoc/updateUserPush"
    static let getAppVersion = "/app/userPatient/getFlag"
    static let nurseList = "/app/nurse/findPatientConsultList"
    static let advisoryList = "/app/consultation/queryDoctorList"
    static let patientMedicalRecords = "/app/order/patientMedicalRecords"
    static let chatRecord = "/app/consultation/queryImRecordList"
    static let uploadImage = "/app/picture/uploadFile_webUploader"
    static let uploadIMAudio = "/imserver/picture/videoUpload"
    static let uploadCondition = "/app/hisPatientState/savePatientState"
    static let uploadNurseCondition = "/app/nurse/nursingOrders"
    static let advisotyDetail = "/app/hisPatientState/queryPatientState"
    static let nurseDetail = "/app/nurse/detail"
    static let endAdvisory = "/app/consultation/updateDiagnoseFlag"
    static let endNurse = "/app/nurse/patientFinishOrder"
    static let inquiryAgreement = "/app/protocol/queryProtocol"
    static let advisoryIsTop = "/app/consultation/updateIsTop"
    static let queryPrescription = "/app/prescription/queryPrescriptionInfoApp"
    
    static let departmentList = "/app/newConsultation/deptNameLists"
    static let doctorList = "/app/newConsultation/doctorInfoLists"
    static let endMeeting = "/app/video/removeConference"
    static let provinceList = "/app/region/getProvinceLists"
    static let cityList = "/app/region/getCityListsByProId"
    static let areaList = "/app/region/getRegionListsByCityId"
    static let doctorReserveList_query = "/app/findDoctor/queryDoctorLists"
    static let doctorReserveList_doctor = "/app/findDoctor/findDoctorLists"
    static let doctorDetail = "/app/findDoctor/doctorInfo"
    static let doctorReserveMenu = "/app/sheard/dictLists"
    static let teamInquiryList = "/app/doctorTeam/doctorTeamList"
    static let teamInquiryDetail = "/app/doctorTeam/doctorTeamDteail"
    static let chatVideoMsgPush = "/app/video/pushConferenceInfo"
    
    static let generateOrder = "/app/order/addOrder"
    static let cloudOrderList = "/app/order/onlineDiagnoseOrderList"
    static let advisoryOrderList = "/app/order/consultationOrderList"
    static let cancelOrder = "/app/order/cancelOrder"
    static let advisoryOrderDetail = "/app/order/consultationOrderDetail"
    static let advisoryOrderDetailFinish = "/app/consultation/endDiagnoseInfo"
    static let advisoryOrderEvaluate = "/app/order/evaluateOrder"
    static let prescriptionOrderList = "/app/order/preOrderList"
    static let drugsOrderStatus = "/app/order/preOrderDetail"
    static let cloudOrderDetail = "/app/order/onlineDiagnoseOrderDetail"
    static let cloudPatientReadMeDetail = "/app/hisPatientState/queryPatientState"
    static let orderRefound = "/app/pay/wechat/refund4DoctorRefuse"
    
    static let reserveDateList = "/source/source/getScheduleSourceNew"
    static let reserveDoctorNumber = "/source/source/registerHeping"
    static let wxPaySubmitOrder = "/app/pay/wechat/appPaySubmit"
    static let wxPayNurseSubmitOrder = "/app/pay/wechat/nurseRequestPay"
    static let queryOrderStatus = "/app/pay/wechat/queryOrderStatus"
    static let queryPrepaidOrder = "/app/pay/wechat/queryPrepaidOrder"
    static let queryAppointmentOrderStatus = "/app/pay/wechat/queryAppointmentOrderStatus"
    static let getCloudNumberAmount = "/app/loadPrice"
    
    static let deptNameLists = "/app/newConsultation/deptNameLists"
    static let registrationRecord = "/app/consultation/offlineOutpList"
    static let instertRegistration = "/app/consultation/insertOfflineOutp"
    static let deleteRegistration = "/app/unRegisterNew"
    static let cancelRegistration = "/app/consultation/cancelOfflineOutp"
    static let registrationDetail = "/app/consultation/offlineOutpInfo"
    
    // MARK: - 2020.6.8
    static let getAppVersionOfAppStore = "/app/userPatient/getVision"
    
    // MARK: - 2020.6.18
    static let getOrderNumbers = "/app/order/orderNumbers"
    
    // MARK: - 2020.11.17
    static let getDepartmentList = "/app/recommend/deptLists"
    static let changeNickname = "/app/userPatient/changeNickName"
    static let helpCenterCategory = "/app/userPatient/helpType"
    static let helpCenterQuestionList = "/app/userPatient/helpList"
    static let submitFeedback = "/app/userPatient/addFeedback"
    static let bannerList = "/app/sheard/bannerList"
    static let doctorPersonInfo = "/app/userDoc/getDocInfo"
    
    static let getPresignedUrl = "/minio/getPresignedUrl"
    static let saveImageToDataBase = "/picture/insertTbresource"
    
    /// 检查单列表
    static let myopiaRecordList = "/app/hidCheck/checkList"
    /// 取消检查预约
    static let myopiaCancelReserve = "/app/hidCheck/cancelCheck"
    /// 检查详情
    static let myopiaRecordDetail = "/app/hidCheck/checkDetail"
    /// 编辑检查信息
    static let myopiaRecordDetailEdit = "/app/hidCheck/editCheckDetail"
    /// 获取医院列表
    static let myopiaHospitalList = "/app/hidCheck/hosList"
    /// 提交预约检查单
    static let submitMyopiaReserve = "/app/hidCheck/createCheck"
    
    ///患者预约项目添加
    static let appointment_projectList_add = "/app/patient/appointment/add"
    
    ///护士预约咨询列表
    static let appointment_nurse_subscribe =
        "/app/nurse/nurseList"
    ///患者预约项目列表
    static let appointment_get_list = "/app/patient/appointment/list"
    
    ///患者端咨询预约列表
    static let appointment_findPatientOrders =
        "/app/nurse/findPatientOrders"
    
    ///患者预约项目详情
    static let appointment_get_listDetail = "/app/patient/appointment/detail"
    
    ///耗材项目列表
    static let appointment_get_itemList = "/app/patient/project/itemList"
    
    ///取消预约单
    static let appointment_cancel = "/app/patient/appointment/appCancel"
    
    ///取消预约咨询单
    static let patient_cancel_order =
        "/app/nurse/patientCancelOrder"
    
    //评价护理订单
    static let appointment_comment = "/app/patient/appointment/comment"
    enum Prescription {
        static let updateOrderStatus = "/app/prescription/updateStatus"
        static let orderDetail = "/app/order/preOrderDetail"
        static let logisticsInfo = "/app/logistics/list"
        static let medicalRecord = "/app/prescription/getPrescriptionMedhisDtoByIdApp"
        static let editOrderByMedicalInsurance = "/app/order/editOrderByMedicalInsurance"
    }
    
    static let getWesternSearchList = "/app/western/westernSearch"
    static let modifyUserStatus = "/app/userPatient/modifyUserStatus"
    /// 临时-查询是否能够使用医保支付
    static let alipayUserGetSwitch = "/app/alipayUser/getSwitch"
    
}

public enum ApiManager {
    case login(paras: [String: Any])
    case checkRegistered(paras: [String: Any])
    case sendSmsCode(paras: [String: Any])
    case register(paras: [String: Any])
    case changePassword(paras: [String: Any])
    /// 忘记密码
    case forgetPassword(paras: [String: Any])
    case logout
    /// 家庭成员列表
    case familyList(paras: [String: Any])
    /// 新增或修改家庭成员
    case familyAddOrEdit(paras: [String: Any])
    /// 删除家庭成员
    case familyDelete(paras: [String: Any])
    /// 云门诊列表
    case cloudClinicList(paras: [String: Any])
    /// 生成云门诊订单
    case generateCloudOrder(paras: [String: Any])
    /// 更改云门诊状态
    case changeCloudStatus(paras: [String: Any])
    /// 获取卡片数据
    case getBindCardList(paras: [String: Any])
    /// 新增卡片
    case addCard(paras: [String: Any])
    /// 绑定卡片
    case bindCard(paras: [String: Any])
    /// 获取家庭成员详情
    case familyMemberDetail(paras: [String: Any])
    /// 提交患者手机审核
    case changePatientPhone(paras: [String: Any])
    /// 收货地址列表
    case receiveAddressList(paras: [String: Any])
    /// 新增和编辑收货地址
    case addAndEditReceiveAddress(paras: [String: Any])
    /// 收货地址详情
    case receiveAddressDetail(paras: [String: Any])
    /// 绑定推送设备
    case bindDeviceTokenForPush(paras: [String: Any])
    /// 获取app版本号
    case getAppVersion
    
    /// 图文咨询列表
    case advisoryList(paras: [String: Any])
    
    /// 图文咨询是否有就诊记录
    case patientMedicalRecords(paras: [String: Any])
    
    ///护士预约咨询列表
    case nurseList(paras: [String: Any])
    
    case chatRecord(paras: [String: Any])
    case uploadImage(_ formDatas: [MultipartFormData], paras: [String: Any])
    /// IM上传音频
    case uploadIMAudio(_ formDatas: [MultipartFormData], paras: [String: Any])
    /// 上传患者病情
    case uploadCondition(paras: [String: Any])
    
    /// 上传护士预约病情
    case uploadNurseCondition(paras: [String: Any])
    
    /// 查看患者自述(护士预约)
    case nurseDetail(paras: [String: Any])
    /// 查看患者自述
    case advisotyDetail(paras: [String: Any])
    /// 确认是否结束图文咨询
    case endAdvisory(paras: [String: Any])
    /// 确认是否结束护士预约订单
    case endNurse(paras: [String: Any])
    /// 查询协议书
    case inquiryAgreement(paras: [String: Any])
    /// 图文咨询置顶和取消
    case advisoryIsTop(paras: [String: Any])
    /// 查询处方
    case queryPrescription(paras: [String: Any])
    
    /// 科室列表
    case departmentList(paras: [String: Any])
    /// 医生列表
    case doctorList(paras: [String: Any])
    /// 结束会议
    case endMeeting(paras: [String: Any])
    /// 获取所有省份
    case provinceList
    /// 根据省份id获取城市
    case cityList(paras: [String: Any])
    /// 根据城市id获取区
    case areaList(paras: [String: Any])
    /// 找医生列表
    case doctorReserveList_doctor(paras: [String: Any])
    /// 新找医生列表
    case doctorReserveList_query(paras: [String: Any])
    /// 医生详情
    case doctorDetail(paras: [String: Any])
    /// 按医生预约下拉菜单
    case doctorReserveMenu(paras: [String: Any])
    /// 团队问诊列表
    case teamInquiryList
    /// 团队问诊详情
    case teamInquiryDetail(paras: [String: Any])
    /// 聊天视频通话推送
    case chatVideoMsgPush(paras: [String: Any])
    
    /// 生成订单
    case generateOrder(paras: [String: Any])
    /// 云门诊订单列表
    case cloudOrderList(paras: [String: Any])
    /// 图文咨询订单列表
    case advisoryOrderList(paras: [String: Any])
    /// 删除订单
    case cancelOrder(paras: [String: Any])
    /// 获取图文咨询未支付订单详情
    case advisoryOrderDetail(paras: [String: Any])
    /// 获取图文咨询已结束订单详情
    case advisoryOrderDetailFinish(paras: [String: Any])
    /// 评价图文问诊订单
    case advisoryOrderEvaluate(paras: [String: Any])
    /// 获取处方订单列表
    case prescriptionOrderList(current: Int)
    /// 云门诊订单详情
    case cloudOrderDetail(paras: [String: Any])
    /// 云门诊订单患者自述详情
    case cloudPatientReadMeDetail(paras: [String: Any])
    /// 订单退款
    case orderRefound(paras: [String: Any])
    
    /// 获取预约时间段列表
    case reserveDateList(paras: [String: Any])
    /// 预约医生号源
    case reserveDoctorNumber(paras: [String: Any])
    /// 微信支付统一下单
    case wxPaySubmitOrder(paras: [String: Any])
    
    /// 护理微信支付统一下单
    case wxPayNurseSubmitOrder(paras: [String: Any])
    
    /// 查询订单状态
    case queryOrderStatus(paras: [String: Any])
    
    /// 支付成功通知
    case queryPrepaidOrder(paras: [String: Any])
    
    /// 查询护理订单状态
    case queryAppointmentOrderStatus(paras: [String: Any])
    
    /// 获取云门诊号源价格
    case getCloudNumberAmount(paras: [String: Any])
    
    ///获取科室分类列表
    case deptNameLists(paras: [String: Any])
    //获取预约挂号列表
    case registrationRecord
    //新增预约挂号
    case instertRegistration(paras: [String: Any])
    //新增预约挂号失败，调这个接口取消号源
    case deleteRegistration(paras: [String: Any])
    //个人中心门诊挂号记录取消预约
    case cancelRegistration(paras: [String: Any])
    //门诊挂号预约详情
    case registrationDetail(paras: [String: Any])
    
    // MARK: - 2020.6.8
    /// 获取AppStore版本号
    case getAppVersionOfAppStore(paras: [String: Any])
    
    // MARK: - 2020.6.18
    /// 获取各订单数
    case getOrderNumbers(paras: [String: Any])
    
    // MARK: - 2020.11.17
    /// 获取科室列表
    case getDepartmentList(paras: [String: Any])
    /// 修改姓名
    case changeNickname(paras: [String: Any])
    /// 帮助中心问题分类
    case helpCenterCategory
    /// 帮助中心问题列表
    case helpCenterQuestionList(paras: [String: Any])
    /// 提交意见反馈
    case submitFeedback(paras: [String: Any])
    /// 首页轮播图列表
    case bannerList
    /// 医生个人信息
    case doctorPersonInfo(paras: [String: Any])
    
    /// 获取上传图片的url
    case getPresignedUrl(paras: [String: Any])
    /// 保存图片到数据库
    case saveImageToDataBase(paras: [String: Any])
    
    /// 检查单列表
    case myopiaRecordList(paras: [String: Any])
    /// 取消检查预约
    case myopiaCancelReserve(paras: [String: Any])
    /// 检查详情
    case myopiaRecordDetail(paras: [String: Any])
    /// 编辑检查信息
    case myopiaRecordDetailEdit(paras: [String: Any])
    /// 获取医院列表
    case myopiaHospitalList(paras: [String: Any])
    /// 提交预约检查单
    case submitMyopiaReserve(paras: [String: Any])
    
    case appointment_projectList_add(paras: [String: Any])
    
    case appointment_get_list(page: Int)
    
    case appointment_findPatientOrders(page: Int)
    
    case appointment_get_listDetail(appointmentId: String)
    
    case appointment_get_itemList(chargeItemType: String)
    
    case appointment_nurse_subscribe(paras: [String: Any])
    
    case appointment_cancel(paras: [String: Any])
    
    case patient_cancel_order(paras: [String: Any])
    
    case appointment_comment(paras: [String: Any])
    
    case updatePrescriptionOrderStatus(id: String, status: Int, backWaybillNo: String, backLogistics: String)
    case prescriptionOrderDetail(orderId: String)
    
    /// 处方订单物流信息
    case prescriptionOrderLogisticsInfo(expressNum: String)
    
    /// 电子病历详情
    case medicalRecordDetail(diagnoseId: String)
    
    /// 药品列表搜索
    case getWesternSearchList(paras: [String: Any])
    /// 用户注销账号
    case modifyUserStatus
    /// 更新订单状态为支付中
    case editOrderByMedicalInsurance(orderId: String, receiveId: String?, getType: Int)
    /// 临时-查询是否能够使用医保支付
    case alipayUserGetSwitch
}

extension ApiManager: TargetType {
    public var baseURL: URL {
        switch self {
        case .uploadIMAudio:
            return URL(string: ApiUrl.imDomain + ApiUrl.imBasic)!
        case .reserveDateList,
             .reserveDoctorNumber:
            return URL(string: ApiUrl.noDomain)!
        case .getPresignedUrl,
             .saveImageToDataBase:
            return URL(string: ApiUrl.imageDomain + ApiUrl.imageBasic)!
        default:
            return URL(string: ApiUrl.domain + ApiUrl.basic)!
        }
    }
    
    public var path: String {
        switch self {
        case .login: return ApiUrl.login
        case .checkRegistered: return ApiUrl.checkRegistered
        case .sendSmsCode: return ApiUrl.sendSmsCode
        case .register: return ApiUrl.register
        case .changePassword: return ApiUrl.changePassword
        case .forgetPassword: return ApiUrl.forgetPassword
        case .logout: return ApiUrl.logout
        case .familyList: return ApiUrl.familyList
        case .familyAddOrEdit: return ApiUrl.familyAddOrEdit
        case .familyDelete: return ApiUrl.familyDelete
        case .cloudClinicList: return ApiUrl.cloudClinicList
        case .generateCloudOrder: return ApiUrl.generateCloudOrder
        case .changeCloudStatus: return ApiUrl.changeCloudStatus
        case .getBindCardList: return ApiUrl.getBindCardList
        case .addCard: return ApiUrl.addCard
        case .familyMemberDetail: return ApiUrl.familyMemberDetail
        case .changePatientPhone: return ApiUrl.changePatientPhone
        case .bindCard: return ApiUrl.bindCard
        case .receiveAddressList: return ApiUrl.receiveAddressList
        case .addAndEditReceiveAddress: return ApiUrl.addAndEditReceiveAddress
        case .receiveAddressDetail: return ApiUrl.receiveAddressDetail
        case .bindDeviceTokenForPush: return ApiUrl.bindDeviceTokenForPush
        case .getAppVersion: return ApiUrl.getAppVersion
        case .getAppVersionOfAppStore: return ApiUrl.getAppVersionOfAppStore
        case .patientMedicalRecords: return ApiUrl.patientMedicalRecords
        case .advisoryList: return ApiUrl.advisoryList
        case .nurseList: return ApiUrl.nurseList
        case .chatRecord: return ApiUrl.chatRecord
        case .endAdvisory: return ApiUrl.endAdvisory
        case .endNurse: return ApiUrl.endNurse
        case .inquiryAgreement: return ApiUrl.inquiryAgreement
        case .advisoryIsTop: return ApiUrl.advisoryIsTop
        case .queryPrescription: return ApiUrl.queryPrescription
        
        case .departmentList: return ApiUrl.departmentList
        case .doctorList: return ApiUrl.doctorList
        case .endMeeting: return ApiUrl.endMeeting
        case .provinceList: return ApiUrl.provinceList
        case .cityList: return ApiUrl.cityList
        case .areaList: return ApiUrl.areaList
        case .doctorReserveList_doctor: return ApiUrl.doctorReserveList_doctor
        case .doctorReserveList_query: return ApiUrl.doctorReserveList_query
        case .doctorDetail: return ApiUrl.doctorDetail
        case .doctorReserveMenu: return ApiUrl.doctorReserveMenu
        case .teamInquiryList: return ApiUrl.teamInquiryList
        case .teamInquiryDetail: return ApiUrl.teamInquiryDetail
        case .chatVideoMsgPush: return ApiUrl.chatVideoMsgPush
            
        case .uploadImage: return ApiUrl.uploadImage
        case .uploadIMAudio: return ApiUrl.uploadIMAudio
        case .uploadCondition: return ApiUrl.uploadCondition
        case .uploadNurseCondition: return ApiUrl.uploadNurseCondition
            
        case .advisotyDetail: return ApiUrl.advisotyDetail
        case .nurseDetail: return ApiUrl.nurseDetail
        case .generateOrder: return ApiUrl.generateOrder
        case .cloudOrderList: return ApiUrl.cloudOrderList
        case .advisoryOrderList: return ApiUrl.advisoryOrderList
        case .cancelOrder: return ApiUrl.cancelOrder
        case .advisoryOrderDetail: return ApiUrl.advisoryOrderDetail
        case .advisoryOrderDetailFinish: return ApiUrl.advisoryOrderDetailFinish
        case .advisoryOrderEvaluate: return ApiUrl.advisoryOrderEvaluate
        case .prescriptionOrderList: return ApiUrl.prescriptionOrderList
        case .prescriptionOrderDetail: return ApiUrl.Prescription.orderDetail
        case .cloudOrderDetail: return ApiUrl.cloudOrderDetail
        case .cloudPatientReadMeDetail: return ApiUrl.cloudPatientReadMeDetail
        case .orderRefound: return ApiUrl.orderRefound
        case .getOrderNumbers: return ApiUrl.getOrderNumbers
            
        case .reserveDateList: return ApiUrl.reserveDateList
        case .reserveDoctorNumber: return ApiUrl.reserveDoctorNumber
        case .wxPaySubmitOrder: return ApiUrl.wxPaySubmitOrder
        case .wxPayNurseSubmitOrder: return ApiUrl.wxPayNurseSubmitOrder
        case .queryOrderStatus: return ApiUrl.queryOrderStatus
        case .queryPrepaidOrder: return ApiUrl.queryPrepaidOrder
        case .queryAppointmentOrderStatus: return ApiUrl.queryAppointmentOrderStatus
        case .getCloudNumberAmount: return ApiUrl.getCloudNumberAmount
            
        case .deptNameLists: return ApiUrl.deptNameLists
        case .registrationRecord: return ApiUrl.registrationRecord
        case .instertRegistration: return ApiUrl.instertRegistration
        case .deleteRegistration: return ApiUrl.deleteRegistration
        case .cancelRegistration: return ApiUrl.cancelRegistration
        case .registrationDetail: return ApiUrl.registrationDetail
            
        case .getDepartmentList: return ApiUrl.getDepartmentList
        case .changeNickname: return ApiUrl.changeNickname
        case .helpCenterCategory: return ApiUrl.helpCenterCategory
        case .helpCenterQuestionList: return ApiUrl.helpCenterQuestionList
        case .submitFeedback: return ApiUrl.submitFeedback
        case .bannerList: return ApiUrl.bannerList
        case .doctorPersonInfo: return ApiUrl.doctorPersonInfo
            
        case .getPresignedUrl: return ApiUrl.getPresignedUrl
        case .saveImageToDataBase: return ApiUrl.saveImageToDataBase
            
        case .myopiaRecordList: return ApiUrl.myopiaRecordList
        case .myopiaCancelReserve: return ApiUrl.myopiaCancelReserve
        case .myopiaRecordDetail: return ApiUrl.myopiaRecordDetail
        case .myopiaRecordDetailEdit: return ApiUrl.myopiaRecordDetailEdit
        case .myopiaHospitalList: return ApiUrl.myopiaHospitalList
        case .submitMyopiaReserve: return ApiUrl.submitMyopiaReserve
        case .appointment_projectList_add: return ApiUrl.appointment_projectList_add
        case .appointment_nurse_subscribe: return
            ApiUrl.appointment_nurse_subscribe
        case .appointment_get_list: return ApiUrl.appointment_get_list
        case .appointment_findPatientOrders: return
            ApiUrl.appointment_findPatientOrders
        case .appointment_get_listDetail: return ApiUrl.appointment_get_listDetail
        case .appointment_get_itemList: return ApiUrl.appointment_get_itemList
        case .appointment_cancel:
            return ApiUrl.appointment_cancel
        case .patient_cancel_order:
            return ApiUrl.patient_cancel_order
        case .appointment_comment:
            return ApiUrl.appointment_comment
        case .updatePrescriptionOrderStatus: return ApiUrl.Prescription.updateOrderStatus
        case .prescriptionOrderLogisticsInfo: return ApiUrl.Prescription.logisticsInfo
        case .medicalRecordDetail: return ApiUrl.Prescription.medicalRecord
        case .getWesternSearchList: return ApiUrl.getWesternSearchList
        case .modifyUserStatus: return ApiUrl.modifyUserStatus
        case .editOrderByMedicalInsurance: return ApiUrl.Prescription.editOrderByMedicalInsurance
        case .alipayUserGetSwitch: return ApiUrl.alipayUserGetSwitch
        }
        
    }
    
    public var method: Moya.Method {
        switch self {
        case .provinceList,
             .cityList,
             .areaList,
             .cancelOrder,
             .advisoryOrderDetail,
             .teamInquiryDetail,
             .getCloudNumberAmount,
             .getOrderNumbers,
             .getDepartmentList,
             .getWesternSearchList,
             .prescriptionOrderLogisticsInfo,
             .medicalRecordDetail,
             .appointment_get_list,
             .appointment_findPatientOrders,
             .appointment_get_listDetail,
             .appointment_get_itemList,
             .nurseList,
             .nurseDetail,
             .patientMedicalRecords,
             .queryPrescription,
             .editOrderByMedicalInsurance,
             .alipayUserGetSwitch:
            return .get
        default: return .post
        }
    }
    
    public var sampleData: Data { return Data(base64Encoded: "Just a test!")! }
    
    public var task: Task {
        switch self {
        case .login(let paras),
             .checkRegistered(let paras),
             .sendSmsCode(let paras),
             .register(let paras),
             .changePassword(let paras),
             .forgetPassword(let paras),
             .familyList(let paras),
             .familyAddOrEdit(let paras),
             .familyDelete(let paras),
             .cloudClinicList(let paras),
             .generateCloudOrder(let paras),
             .changeCloudStatus(let paras),
             .getBindCardList(let paras),
             .addCard(let paras),
             .familyMemberDetail(let paras),
             .changePatientPhone(let paras),
             .bindCard(let paras),
             .receiveAddressList(let paras),
             .addAndEditReceiveAddress(let paras),
             .receiveAddressDetail(let paras),
             .bindDeviceTokenForPush(let paras),
             .nurseList(let paras),
             .nurseDetail(let paras),
             .advisoryList(let paras),
             .chatRecord(let paras),
             .endAdvisory(let paras),
             .inquiryAgreement(let paras),
             .advisoryIsTop(let paras),
             .queryPrescription(let paras),
             
             .departmentList(let paras),
             .doctorList(let paras),
             .endMeeting(let paras),
             .cityList(let paras),
             .areaList(let paras),

             .doctorDetail(let paras),
             .doctorReserveMenu(let paras),
             .teamInquiryDetail(let paras),
             .chatVideoMsgPush(let paras),
             
             .uploadCondition(let paras),
             .advisotyDetail(let paras),
            
             .generateOrder(let paras),
             .cloudOrderList(let paras),
             .advisoryOrderList(let paras),
             .cancelOrder(let paras),
             .advisoryOrderDetail(let paras),
             .advisoryOrderDetailFinish(let paras),
             .advisoryOrderEvaluate(let paras),
             .cloudOrderDetail(let paras),
             .cloudPatientReadMeDetail(let paras),
             .orderRefound(let paras),
             .getCloudNumberAmount(let paras),
             .getOrderNumbers(let paras),
             .wxPaySubmitOrder(let paras),
             .queryOrderStatus(let paras),
             .queryAppointmentOrderStatus(let paras),
             .deptNameLists(let paras),
             .instertRegistration(let paras),
             .deleteRegistration(let paras),
             .cancelRegistration(let paras),
             .registrationDetail(let paras),
             .getAppVersionOfAppStore(let paras),
             .getWesternSearchList(let paras),
             .getDepartmentList(let paras),
             .changeNickname(let paras),
             .helpCenterQuestionList(let paras),
             .submitFeedback(let paras),
             .doctorPersonInfo(let paras),
             .doctorReserveList_doctor(let paras),
             .getPresignedUrl(let paras),
             .patientMedicalRecords(let paras),
             .myopiaRecordList(let paras),
             .myopiaCancelReserve(let paras),
             .myopiaRecordDetail(let paras),
             .myopiaHospitalList(let paras),
             .submitMyopiaReserve(let paras):
            print(paras)
            return .requestParameters(parameters: paras, encoding: URLEncoding.default)
            
        case .reserveDateList(let paras),
             .reserveDoctorNumber(let paras),
             .saveImageToDataBase(let paras),
             .appointment_projectList_add(let paras),
             .appointment_nurse_subscribe(let paras),
             .wxPayNurseSubmitOrder(let paras),
             .appointment_cancel(let paras),
             .patient_cancel_order(let paras),
             .queryPrepaidOrder(let paras),
             .appointment_comment(let paras),
             .doctorReserveList_query(let paras),
             .uploadNurseCondition(let paras),
             .endNurse(let paras),
             .myopiaRecordDetailEdit(let paras):
            print(paras)
            return .requestParameters(parameters: paras, encoding: JSONEncoding.default)
        
        case .uploadImage(let formDatas, let paras),
             .uploadIMAudio(let formDatas, let paras):
            print(paras)
            return .uploadCompositeMultipart(formDatas, urlParameters: paras)
        case .logout,
             .provinceList,
             .teamInquiryList,
             .getAppVersion,
             .registrationRecord,
             .helpCenterCategory,
             .bannerList:
            return .requestPlain
            
        case .prescriptionOrderList,
             .modifyUserStatus,
             .updatePrescriptionOrderStatus:

            YSGLog("\(path) - \(params)")
            return .requestParameters(parameters: params, encoding: JSONEncoding.default)
        case .prescriptionOrderDetail,
             .prescriptionOrderLogisticsInfo,
             .appointment_get_itemList,
             .appointment_get_listDetail,
             .appointment_get_list,
             .appointment_findPatientOrders,
             .medicalRecordDetail,
             .editOrderByMedicalInsurance,
             .alipayUserGetSwitch:
            YSGLog("\(path) - \(params)")
            return .requestParameters(parameters: params, encoding: URLEncoding.default)
        }
    }
    
    public var headers: [String : String]? {
        switch self {
        case .login, .register, .checkRegistered, .sendSmsCode: return nil
        default: return ["Authorization": UserDefaults.token]
        }
    }
    
    private var params: [String: Any] {
        var paramaters: [String: Any] = [:]
        switch self {
        case .prescriptionOrderList(let current):
            return ["current": current, "size": 20]
        case .updatePrescriptionOrderStatus(let id, let status, let backWaybillNo, let backLogistics):
            return ["id": id, "status": status, "backWaybillNo": backWaybillNo, "backLogistics": backLogistics]
        case .prescriptionOrderDetail(let orderId):
            return ["orderId": orderId]
        case .prescriptionOrderLogisticsInfo(let expressNum):
            return ["id": expressNum]
        case .medicalRecordDetail(let diagnoseId):
            return ["id": diagnoseId]
        case .appointment_get_itemList(let chargeItemType):
            return ["chargeItemType": chargeItemType]
        case.appointment_get_listDetail(let appointmentId):
            return ["appointmentId": appointmentId]
        case.appointment_get_list(let page):
            return ["page": page]
        case .modifyUserStatus:
            return ["userStatus" : "0","userSource" : "1"]
        case let .editOrderByMedicalInsurance(orderId, receiveId, getType):
            paramaters["orderId"] = orderId
            paramaters["receiveId"] = receiveId
            paramaters["getType"] = getType
        default:
            return [:]
        }
        return paramaters
    }
}

public enum OutpatientType: Int {
    /// 图文问诊
    case chat = 1
    /// 云门诊
    case cloud = 2
    /// 护理咨询
    case nurse = 3
}
